package com.zto.sch.base.normal;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @program: sch-diy-parent
 * @description:
 * @author: sch
 * @create: 2021-03-31 15:36
 **/
public class ListIterator {
    public static void main(String[] args) {
//        for (String s : list) {
//            if ("a".equals(s)) {
//                list.add("c");
//            }
//        }
//        System.out.println(list);
        List<String> list = new ArrayList<>();
        list.add("a");
        list.add("b");
        list.add("c");

        Iterator<String> iterator = list.iterator();
        while (iterator.hasNext()) {
            if (iterator.next().equals("b")) {
//                list.remove("c");
                list.add("d");
            }
        }
        System.out.println(list);
    }
}
